﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace proyecto
{
    /// <summary>
    /// Lógica de interacción para LineChart_Design.xaml
    /// </summary>
    public partial class LineChart_Design : Window
    {

        int nSeries;
        ComboBox[] combos;

        public LineChart_Design()
        {
            InitializeComponent();
        }

        public LineChart_Design(data matrix, int table)
        {
            
            nSeries = 0;
            InitializeComponent();

            for (int i = 0; i < matrix.getnRows(); i++)
            {
                ListBoxItem newItem = new ListBoxItem();
                newItem.Content = matrix.getRow(table, i)[0].ToString();
                listBox1.Items.Add(newItem);
            }

            

            
        }


        private void button2_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < listBox1.Items.Count; i++)
                if ((listBox1.Items[i] as ListBoxItem).IsSelected)
                    nSeries++;
            if (nSeries > 0)
            {
                
                this.DialogResult = true;
            }
            else
                this.Close();

        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        public int get_nSeries()
        {
            return nSeries;
        }


        public bool isSelected(int i)
        {
            return ((listBox1.Items[i] as ListBoxItem).IsSelected);

        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            listBox1.SelectAll();
            for (int i = 0; i < listBox1.Items.Count; i++)
                (listBox1.Items[i] as ListBoxItem).IsSelected = true;

        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            
            for (int i = 0; i < listBox1.Items.Count; i++)
                (listBox1.Items[i] as ListBoxItem).IsSelected = false;
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < listBox1.Items.Count; i++)
                if ((listBox1.Items[i] as ListBoxItem).IsSelected)
                    (listBox1.Items[i] as ListBoxItem).IsSelected = false;
                else
                    (listBox1.Items[i] as ListBoxItem).IsSelected = true;
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            string filter = textBox2.Text;

            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                string item = (listBox1.Items[i] as ListBoxItem).Content.ToString();

                if (item.Length >= filter.Length)
                    item = item.Substring(0, filter.Length);
                if (item == filter)
                    
                    (listBox1.Items[i] as ListBoxItem).IsSelected = true;
            }
        }

        private void button7_Click(object sender, RoutedEventArgs e)
        {
            string filter = textBox2.Text;

            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                string item = (listBox1.Items[i] as ListBoxItem).Content.ToString();

                if (item.Length >= filter.Length)
                    item = item.Substring(0, filter.Length);
                if (item == filter)
                    (listBox1.Items[i] as ListBoxItem).IsSelected = false;
            }
        }



    }
}